home *** CD-ROM | disk | FTP | other *** search
RISC OS BBC BASIC V Source | 2002-04-09 | 3.2 KB | 133 lines |
- >SnigLib.File
- This contains routines which deal with file and loading text into memory
- blocks. You may use this code in your applications as long as you inform
- me. owen.griffin@btinternet.com
- PROCFile_Create
- Creates a file of a set type (text)
- -> Path and file type
- File_Create(Path$,Type$)
- ("Create "+Path$)
- ("Settype "+Path$+" "+Type$)
- FNFile_ReadDate
- Find the date of a file
- -> Path
- <- Date in file format
- File_ReadDate(Path$)
- Block%,Buffer%,Term%
- Block% 256
- Buffer% 10
- Term%=0
- "OS_File",17,Path$
- ,,Block%!4,!Block%
- "OS_ConvertDateAndTime",Block%,Buffer%,256,"%W3 %DY-%M3-%YR"
- ,Term%
- ?Term%=&D
- =$Buffer%
- FNFile_Exists
- Find the existance of file
- -> Path
- <- TRUE/FALSE
- File_File(Path$)
- Exists%
- "XOS_File",&05,Path$
- Exists%
- =(Exists%=1)
- FNFile_Size
- Finds the size of the file
- -> Path
- <- Size
- File_Size(FilePath$)
- Size%,Type%
- "OS_File",&05,FilePath$
- Type%,,,,Size%
- Type%=0
- 0, "File not found"
- =Size%
- FNFile_FileType
- Finds the file type or object of a path name
- -> Path of a file; output type
- <- Depending on Output%
- 1 = Text file type
- 2 = Object type
- 3 = Hex number text
- File_FileType(FilePath$,Output%)
- Object%,FileTypeStr%
- Type$="":Type%=0:Object%=0
- FileTypeStr% 9
- FileTypeStr%?8=13
- "OS_File",21,FilePath$
- Object%,,,,,,Type%
- Object%<>1
- ERROR 0,"Object type is not correct"
- Output%
- GC
- "OS_FSControl",18,,&FFF
- ,,!FileTypeStr%,FileTypeStr%!4
- =$(FileTypeStr%)
- =Object%
- =Type%
- =Object%
- FNText_Load
- -> Path of a text-like file, var for size
- <- Memory block containing file
- Text_Load(Path$,
- Size%)
- Data%,MaxSize%
- MaxSize%=(64*1024)
- Data% MaxSize%-1
- "OS_File",16,Path$,Data%,0
- ,,,,Size%
- =Data%
- FNText_Blank
- Creates a blank text block
- <- Text block
- Text_Blank
- Data%,MaxSize%
- MaxSize%=(64*1024)
- Data% MaxSize%-1
- =Data%
- FNText_NextLine
- Reads the next line from a text block
- -> Block containing text file and position of block
- <- Next line of the file and position
- Text_NextLine(TextBlock%,
- Position%,Size%)
- Result$,Char%
- Result$=""
- Char%<>13
- Char%<>10
- Position%<Size%
- o Char%=TextBlock%?Position%
- Char%<>13
- Char%<>10
- Result$+=
- Char%
- Position%+=1
- =Result$
- PROCText_AddLine
- Adds a line of text to the end of the file block
- -> Block containing text, size and line
- Text_AddLine(TextBlock%,
- Size%,Line$)
- Len%,Pos%,C%
- Len%=
- (Line$)
- TextBlock%?(Size%)=10
- Pos%=Size%+1
- Size%+Len%
- % TextBlock%?Pos%=
- Line$,C%,1))
- C%+=1
- Pos%
- Size%+=Len%+1
- TextBlock%?(Size%)=10
- Size%+=1
- PROCText_DisplayText
- Displays the text in a text block
- Text_DisplayText(TextBlock%,Size%)
- Pos%
- Pos%=0
- (TextBlock%?Pos%);
- Pos%+=1
- Pos%>=Size%
-